import {requested} from './axiosed';
//新增用户
export async function addUser(name, phone, password) {
  var url = '/api/user/add';
  let data = {
    name:name,
    phone:phone,
    password:password
  };
  let res = await requested(url,'post',data);
  return res.data;
}
//获取用户总数
export async function getUserCount() {
  var url = '/api/user/count';
  let res = await requested(url);
  return res.data.data;
}
// 获取一名用户信息
export async function getUserById(id) {
  var url = '/api/user/read/';
  if (id !== undefined) {
    url+=id;
  }
  let res = await requested(url);
  return res.data.data;
}
// 获取用户信息
export async function getUserByPhone(phone,curPage = 1,pageSize = 10) {
  var url = '/api/user/searchByPhone/?phone='+phone+'&curPage='+curPage+'&pageSize='+pageSize;
  let res = await requested(url);
  return res.data.data;
}
//获取一页用户信息，默认第一页，一页十条
export async function getUserList(curPage = 1,pageSize = 5) {
  var url = '/api/user/readList?curPage='+curPage+'&pageSize='+pageSize;
  let res = await requested(url);
  return res.data.data;
}
//获取一截时间流
export async function getTimeList(curPage = 1,pageSize = 10) {
  var url = '/api/user/timeList?curPage='+curPage+'&pageSize='+pageSize;
  let res = await requested(url);
  return res.data.data.data;
}
//修改用户信息
export async function updateUser(id, name, phone, password) {
  var url = '/api/user/update';
  let data = {
    id:id,
    name:name,
    phone:phone,
    password:password
  };
  let res = await requested(url,'post',data);
  return res.data;
}
//注销用户
export async function deleteUser(id) {
  var url = 'api/user/delete/';
  if (id !== undefined) {
    url+=id;
  }
  let res = await requested(url);
  return res.data;
}
